const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
const db = cloud.database()
exports.main = async (event, context) => {
  return await db.collection('user').where({
    openid: event.openid,
    _id: event._id
  })
    .update({
      data: {
        nickName: event.nickName,
        gender: event.gender,
        language: event.language,
        city: event.city,
        province: event.province,
        country: event.country,
        avatarUrl: event.avatarUrl,
        role: event.role
      },
    })
}